The C# source below uses the Selerix .NET library and web services to prepare a Selerix data Transmittal, post it to BenSelect and verify that the transmission was successful. Values in orange indicate data fields that differ by applicant/family.
using System;
using System.IO;
using System.Net;
using System.Text; // Encoding
using System.Xml; // For parsing XML
using Selerix.Foundation; // Selerix Web Services API
using Selerix.BusinessObjects; // Selerix General Purpose Objects
using Selerix.Foundation.Data; // Selerix Data Model
// The Transmittal object encapsulates all possible data used by Selerix Web Services
theTransmittalObj = new Transmittal();
// All properties below are required except the Version property
theTransmittalObj.SenderID = Guid.NewGuid();
theTransmittalObj.Group = new Group();
theTransmittalObj.PortfolioID = new Guid("87902A63-3EF7-43FA-ADA2-D9C9C9B4E0FE");
theTransmittalObj.Type = TransmittalType.UploadApplicants;
theTransmittalObj.Version = "1.2 2017-04-23"; // optional
// This example uses the same address for all family members. Address is optional.
Address theAddress = new Address()
{
Line1 = "123 Circle Drive", // Same as "Address 1" in census template
Line2 = "#345",
City = "Seattle",
State = "WA",
Zip = "98118"
};
// Add the employee and family members to be offered coverages.
theTransmittalObj.Applicants = new ApplicantCollection();
theTransmittalObj.Applicants.Add(new Applicant()
{
// The ID must be unique to each family being uploaded.
ID = "987654321",
Relationship = Relationship.Employee,
// The system needs a way to identify the employee in the transmittal.
// This can be accomplished using either an Employee ID, a Social Security
// Number, or First or Last Name and Date of Birth. EmployeeIdent is the
// same as the Employee ID shown in the Employee's Employment page.
// Option 1: use employee ID
EmployeeIdent = "Employee_12345",
// Option 2: use employee SSN
SSN = "465465465",
// Option 3, at least a first or last name and birthdate
FirstName = "Douglas",
LastName = "Fir",
BirthDate = new DateTime(1980, 1, 15),
// The Employee applicant must contain an Employment object that describes the
// employee's job in the company. This information is required where indicated and
// is used by BenSelect business rules processing. Because all string values below
// are FREE FORM text, they must exactly match values defined in case setup. Remember
// to check with the case builder to see if other rules dictate additional data here.
Employment = new Employment(null)
{
Department = "Product Development", // Required
HireDate = new DateTime(2012, 1, 1), // Required
JobClass = "Salary", // Required
Location = "JAX", // Required
AsOfDate = DateTime.UtcNow,
DeductionFrequency = 24,
EligibilityDate = new DateTime(2012, 1, 1),
HoursPerWeek = 40,
PayGroup = "Bi-Weekly",
PayrollFrequency = 26,
Salary = 60000, // 'Gross Salary' in census
Status = EmployeeStatus.Active,
Title = "Integration Engineer"
}
});
// Add the employee's spouse
theTransmittalObj.Applicants.Add(new Applicant()
{
DependentNumber = "1",
ID = "8675309", // Only useful when debugging XML
EmployeeID = "987654321", // Required. Ties dependent back to the employee
EmployeeIdent = "Employee_12345", // Called Employee ID on admin site
Relationship = Relationship.Spouse,
FirstName = "Burlie",
LastName = "Fir",
SSN = "999887777",
BirthDate = new DateTime(1985, 3, 31),
Sex = Gender.Female,
Address = theAddress
});
// Add the employee's daughter
theTransmittalObj.Applicants.Add(new Applicant()
{
DependentNumber = "2",
ID = "1248163264128", // Only useful when debugging XML
EmployeeID = "987654321", // Required. Must match employee
EmployeeIdent = "Employee_12345",
Relationship = Relationship.Child,
FirstName = "Curly",
LastName = "Fir",
SSN = "222334444",
BirthDate = new DateTime(2012, 2, 29),
Sex = Gender.Female,
Address = theAddress
});
// Agents may be needed if policy requires licensed agents, or commission is involved.
// Otherwise the agent information below is optional.
Address agentAddr = new Address()
{
Line1 = "2112 Rush Road",
City = "Seattle",
State = "WA",
Zip = "98110"
};
// Agent licenses apply when agents are licensed by state. Add two examples.
License agentLicenseWA = new License()
{
State = "WA",
StateLicense = "WA590X10"
};
License agentLicenseTX = new License()
{
State = "TX",
StateLicense = "TX590X10"
};
LicenseCollection licenses = new LicenseCollection();
licenses.Add(agentLicenseTX);
licenses.Add(agentLicenseWA);
theTransmittalObj.Agents = new AgentCollection();
theTransmittalObj.Agents.Add(new Agent() {
FirstName = "Polly",
LastName = "Ester",
Address = agentAddr,
StateLicense = licenses,
Organization = "National Insurance Sales, Inc.",
EnrollerType = EnrollerType.FaceToFace,
EffectiveDate = new DateTime(2017, 1, 1),
PhoneMobile = "2066842489",
PhoneWork = "2066845600",
Email = "pollyanna@NationalInsuranceSales.com",
Number = "12345",
Split = (decimal)3.141592
});
// Serialize the Transmittal object to XML using Selerix helper
string outboundXML = SerializationHelper.SerializeToString(theTransmittalObj);
// Instantiate an Enrollment object which handles communication over SOAP
SelerixWS.Enrollment enrollment = new SelerixWS.Enrollment();
// Set the URL to the value provided by Selerix. This will likely differ from the example.
enrollment.Url = "https://benselect.com/qx/enrollment.asmx";
// Change default .NET security protocol for use by BenSelect
System.Net.ServicePointManager.SecurityProtocol =
SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls |
SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
// Transmit the XML using the Upload method which handles the HTTP Post, passing
// the ID and password of the user setup on the case with the QX Enroller role
string returnedXML = enrollment.Upload("testcaseqxenroller", "thePassword", outboundXML);
// Here's an easy way to see if there was an error
if (returnedXML.ToUpperInvariant().Contains("ERROR")
throw new Exception("Upload failed: refer to XML returned for error reason");
// Parse the XML to check the return status
XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml(returnedXML);
XmlNode result = xdoc.DocumentElement.SelectSingleNode("/Transmittal/TransmittalResult");
if (result.Attributes["Status"].Value != "OK")
throw new Exception("Upload failed: did not receive an 'OK' return status");
// Done!